package main

import "fmt"

func main() {

	jobs:=make(chan int,5)

	done:=make(chan bool)

	go func() {

		for{
			j,more:=<-jobs
			fmt.Printf("j=%d,more=%v \n",j,more)
			if more{
				fmt.Println("received job",j)
			}else{
				fmt.Println("received all jobs")
				done<-false
				return
			}
		}
	}()

	for j:=1;j<=3;j++{
		jobs<-j
		fmt.Println("sent job ",j)
	}

	close(jobs)

	fmt.Println("send all jobs")

	fmt.Printf("done=%v",<-done)
}
